package com.string;

/**
 * @author: csh
 * @Date: 2021/6/22 11:39
 * @Description:
 */
public class StringTest4 {
    static final int MAX_COUNT=1000 * 10000;
    static final String[] arr =new String[MAX_COUNT];
    public static void main(String[] args) {
        Integer[] data = new Integer[]{1,2,3,4,5,6,7,8,9,10};

        long start = System.currentTimeMillis();
        for (int i = 0; i < MAX_COUNT; i++) {
            arr[i] = new String(String.valueOf(data[i%data.length])).intern(); //1133 java.lang.String[]	40,045,584 B (37.8%)	1,273 (0.1%)
//            arr[i] = new String(String.valueOf(data[i%data.length]));   // 2897  char[]	242,338,040 B (45.8%)	10,022,143 (49.9%)
        }
        long end = System.currentTimeMillis();
        System.out.println("花费的时间为:"+(end-start));
        try {
            Thread.sleep(100000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
